<template>
  <div class="shipment">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">发运订单管理</span>
        <el-button style="float: right;" type="primary" @click="dialogOpen('add')" v-if="USER.auth.indexOf('outOperation_shipment_add')!==-1">新增发运订单</el-button>
      </div>
      <s-table
        :table="table"
        ref="table"
        @http="tableWatch">
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="125">
          <template scope="s">
            <el-button type="info" size="mini" @click="dialogSearchOpen(s.row)" icon="search"></el-button>
            <el-button type="success" icon="edit" size="mini" @click="tableEdit(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_edit')!==-1"></el-button>
            <el-tooltip placement="top">
              <div slot="content">更多可用操作</div>
              <el-popover
                popper-class="demo-table-expand"
                placement="right"
                title="更多可用操作"
                trigger="click">
                <slot name="content">
                  <div>
                    <el-button type="danger" icon="delete" size="mini" @click="tableDelete(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_disable')!==-1"></el-button>
                    <el-button type="info"  size="mini" @click="tableExamine(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_examine')!==-1">审核订单</el-button>
                    <el-button type="success"  size="mini" @click="tableImport(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_import')!==-1">导入订单</el-button>
                    <el-button type="warning"  size="mini" @click="tableComplete(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_sign')!==-1">标记完成</el-button>
                    <el-button type="info"  size="mini" @click="tableCreate(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_create')!==-1">创建波次</el-button>
                    <el-button type="success"  size="mini" @click="tableRemove(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_remove')!==-1">订单拆单</el-button>
                    <el-button type="success"  size="mini" @click="tableCancel(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_cancel')!==-1">取消拆单</el-button>
                    <el-button type="warning"  size="mini" @click="tableAllot(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_allot')!==-1">分配</el-button>
                    <el-button type="warning"  size="mini" @click="tableAdditionalAllot(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_additionalallot')!==-1">追加分配</el-button>
                    <el-button type="warning"  size="mini" @click="tableCancelAllot(s.row)" v-if="USER.auth.indexOf('business_customerFile_search')!==-1">取消分配</el-button>
                    <el-button type="info"  size="mini" @click="tablePacking(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_packing')!==-1">装箱</el-button>
                    <el-button type="info"  size="mini" @click="tableAdditionalPacking(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_additionalpacking')!==-1">追加装箱</el-button>
                    <el-button type="success"  size="mini" @click="tablePicking(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_picking')!==-1">拣货</el-button>
                    <el-button type="success"  size="mini" @click="tableAdditionalPicking(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_additionalpicking')!==-1">追加拣货</el-button>
                    <el-button type="warning"  size="mini" @click="tableShipment(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_shipment')!==-1">发运</el-button>
                    <el-button type="warning"  size="mini" @click="tableAdditionalShipment(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_additionalshipment')!==-1">追加发运</el-button>
                    <el-button type="warning"  size="mini" @click="tableSplitSingleDetailed(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_splitsingledetailed')!==-1">查看拆单明细</el-button>
                    <el-button type="warning"  size="mini" @click="tableAllotDetailed(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_allotdetailed')!==-1">查看分配明细</el-button>
                    <el-button type="warning"  size="mini" @click="tablePackingDetailed(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_packingdetailed')!==-1">查看装箱明细</el-button>
                    <el-button type="warning"  size="mini" @click="tableExportPackingDetailed(s.row)">导出装箱明细</el-button>
                    <el-button type="warning"  size="mini" @click="tableExportShipmentDetailed(s.row)">导出发运明细</el-button>
                    <el-button type="warning"  size="mini" @click="tablePrintSorting(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_printsorting')!==-1">打印分拣单</el-button>
                    <el-button type="warning"  size="mini" @click="tablePrintMergeSorting(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_printmergesorting')!==-1">打印合并分拣单</el-button>
                    <el-button type="warning"  size="mini" @click="tablePrintPackingLabelDetailed(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_printpackingLabeldetailed')!==-1">打印装箱标签</el-button>
                    <el-button type="warning"  size="mini" @click="tablePrintPackingLabel(s.row)" v-if="USER.auth.indexOf('outOperation_shipment_printpackingLabeldetailed1')!==-1">打印装箱标签(无明细)</el-button>
                  </div>
                </slot>
                <el-button slot="reference" type="info" icon="more" :plain="true" size="mini" class="__reference"></el-button>
              </el-popover>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-row>
          <el-col :xs="24" :lg="{span: 8, offset: 0}">
            <el-form-item label="自定列名">
              <el-select
                class="__tabel_column"
                name="testSelet1"
                value-key="prop"
                multiple-limit.number="4"
                v-model="table.tableColumn" multiple placeholder="请选择">
                <el-option
                  v-for="item in table.tableColumnAll"
                  :key="item.prop"
                  :label="item.label"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="SO编号" prop="fybh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_fybh"
                        placeholder="SO编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="客户地址" prop="khdz">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khdz"
                        placeholder="客户地址" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="订单号" prop="khddh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khddh"
                        placeholder="客户订单号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="SO类型" prop="fylx">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_fylx"
                        placeholder="SO类型" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="SO状态" prop="fyzt">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_fyzt"
                        placeholder="SO状态" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="客户编号" prop="khbh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khbh"
                        placeholder="客户编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="客户名称" prop="khmc">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khmc"
                        placeholder="客户名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="可用操作" prop="kycz">
              <div class="s-content">
                <el-button @click="tableSetSearch('table')" size="small">重置搜索</el-button>
              </div>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 8, offset: 0}">
            <el-form-item label="创建时间" prop="khcjsj">
              <el-date-picker
                v-model="autoVue_table_khcjsj"
                type="daterange"
                placeholder="客户创建时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="创建时间" prop="cjsj">
              <el-date-picker
                v-model="autoVue_table_cjsj"
                type="daterange"
                placeholder="WMS创建时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="发货时间" prop="jhfhsj">
              <el-date-picker
                v-model="autoVue_table_jhfhsj"
                type="daterange"
                placeholder="计划发货时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="交货时间" prop="yqjhsj">
              <el-date-picker
                v-model="autoVue_table_yqjhsj"
                type="daterange"
                placeholder="要求交货时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="审核状态" prop="shzt">
              <el-select v-model="autoVue_table_shzt"
                         placeholder="是否审核">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  label="未审核"
                  value="0"></el-option>
                <el-option
                  label="已审核"
                  value="1"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="拣货状态" prop="jhzt">
              <el-select v-model="autoVue_table_jhzt"
                         placeholder="是否拣货">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  label="初始"
                  value="0"></el-option>
                <el-option
                  label="部分拣货"
                  value="1"></el-option>
                <el-option
                  label="全部拣货"
                  value="2"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="波次状态" prop="bczt">
              <el-select v-model="autoVue_table_bczt"
                         placeholder="是否加入">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  label="未加入"
                  value="0"></el-option>
                <el-option
                  label="已加入"
                  value="1"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="拆单状态" prop="cdzt">
              <el-select v-model="autoVue_table_cdzt"
                         placeholder="是否拆弹">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  label="未拆单"
                  value="0"></el-option>
                <el-option
                  label="已拆单"
                  value="1"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="装箱状态" prop="zxzt">
              <el-select v-model="autoVue_table_zxzt"
                         placeholder="是否装箱">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  label="未装箱"
                  value="0"></el-option>
                <el-option
                  label="已装箱"
                  value="1"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="交货方式" prop="jhfs">
              <el-select v-model="autoVue_table_jhfs"
                         placeholder="交货方式">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  label="发运"
                  value="0"></el-option>
                <el-option
                  label="自提"
                  value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 8, offset: 0}">
            <el-form-item label="启用多选" prop="multiSelect">
              <el-switch
                v-model="table.multiSelect"
                on-color="#13ce66"
                off-color="#ff4949">
              </el-switch>
              <el-button @click="clearMuti" type="danger" size="small" style="margin-left: 25px" v-if="table.multiSelect">清空选择</el-button>
            </el-form-item>
            <transition name="el-zoom-in-top">
              <el-form-item label="多选操作" prop="multiSelect" v-if="table.multiSelect">
                <el-row>
                  <el-col :span="8">
                    <el-button size="small" type="danger" @click="tableDelete('')" v-if="USER.auth.indexOf('outOperation_shipment_disable')!==-1">多选删除</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableExamine('')" v-if="USER.auth.indexOf('outOperation_shipment_examine')!==-1">多选审核</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableComplete('')" v-if="USER.auth.indexOf('outOperation_shipment_sign')!==-1">多选标记</el-button>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableCreate('')" v-if="USER.auth.indexOf('outOperation_shipment_create')!==-1">创建波次</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableRemove('')" v-if="USER.auth.indexOf('outOperation_shipment_remove')!==-1">订单拆单</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableCancel('')" v-if="USER.auth.indexOf('outOperation_shipment_cancel')!==-1">取消拆单</el-button>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableAllot('')" v-if="USER.auth.indexOf('outOperation_shipment_allot')!==-1">多选分配</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableAdditionalAllot('')" v-if="USER.auth.indexOf('outOperation_shipment_additionalallot')!==-1">追加分配</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableCancelAllot('')" v-if="USER.auth.indexOf('business_customerFile_search')!==-1">取消分配</el-button>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tablePacking('')" v-if="USER.auth.indexOf('outOperation_shipment_packing')!==-1">多选装箱</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableAdditionalPacking('')" v-if="USER.auth.indexOf('outOperation_shipment_additionalpacking')!==-1">追加装箱</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tablePicking('')" v-if="USER.auth.indexOf('outOperation_shipment_picking')!==-1">多选拣货</el-button>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableAdditionalPicking('')" v-if="USER.auth.indexOf('outOperation_shipment_additionalpicking')!==-1">追加拣货</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableShipment('')">多选发运</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableAdditionalShipment('')" v-if="USER.auth.indexOf('outOperation_shipment_additionalshipment')!==-1">追加发运</el-button>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableExportPackingDetailed('')">导出装箱</el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button size="small" type="info" @click="tableShipment('')" v-if="USER.auth.indexOf('outOperation_shipment_shipment')!==-1">导出发运</el-button>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-button size="small" type="info" @click="tablePrintSorting('')" v-if="USER.auth.indexOf('outOperation_shipment_printsorting')!==-1">打印分拣单</el-button>
                  </el-col>
                  <el-col :span="12">
                    <el-button size="small" type="info" @click="tablePrintMergeSorting('')" v-if="USER.auth.indexOf('outOperation_shipment_printmergesorting')!==-1">打印合并分拣单</el-button>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-button size="small" type="info" @click="tablePrintPackingLabelDetailed('')" v-if="USER.auth.indexOf('outOperation_shipment_printpackingLabeldetailed')!==-1">打印装箱</el-button>
                  </el-col>
                  <el-col :span="12">
                    <el-button size="small" type="info" @click="tablePrintPackingLabel('')" v-if="USER.auth.indexOf('outOperation_shipment_printpackingLabeldetailed1')!==-1">打印装箱</el-button>
                  </el-col>
                </el-row>
              </el-form-item>
            </transition>
          </el-col>
        </el-row>
      </s-table>
    </el-card>

    <s-dialog :dialog="dialog" :close="dialogInit">
      <p slot="title">{{dialog.title}}发运订单 <span>{{USER.user.orgName}}</span></p>
      <el-tabs v-model="dialog.activeName">
        <el-tab-pane label="发运订单表头" name="1" disabled>
          <s-form :form="formDialog1" ref="formDialog1">
            <el-row>
              <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                <el-form-item prop="fybh" label="SO编号">
                  <el-input
                    type="text"
                    v-model="formDialog1.fybh"
                    placeholder="SO编号"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                <el-form-item prop="yxj" label="优先级">
                  <el-select v-model="formDialog1.yxj" placeholder="请选择">
                    <el-option
                      v-for="item in SHIPMENT.yxj"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                <el-form-item prop="khid" label="客户编号">
                  <el-select v-model="formDialog1.khid"
                             filterable
                             remote
                             placeholder="请选择客户编号"
                             @change="dialogRemoteKhbhid"
                             :remote-method="dialogRemoteKhbh">
                    <el-option
                      v-for="item in dialog.wmsshipmentorder"
                      :key="item.id"
                      :label="item.khbh + '  ' + item.khmc"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 23, offset: 0}">
                <el-collapse v-model="dialog.activeNameCollapse" accordion v-if="formDialog1.khid">
                  <el-collapse-item title="客户详情" name="1">
                    <el-row>
                      <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                        <el-form-item prop="khmc" label="客户名称">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog1.khmc"
                            placeholder="客户名称"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                        <el-form-item prop="xlmc" label="路线名称">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog1.xlmc"
                            placeholder="路线名称"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :xs="24" :lg="{span: 8, offset: 1}" class="">
                        <el-form-item prop="lxrdh" label="联系电话">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog1.lxrdh"
                            placeholder="联系电话"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                        <el-form-item prop="lxrxm" label="联系人">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog1.lxrxm"
                            placeholder="联系人"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :xs="24" :lg="{span: 16, offset: 1}" class="">
                        <el-form-item prop="khdz" label="客户地址">
                          <el-input
                            type="text"
                            disabled
                            v-model="formDialog1.khdz"
                            placeholder="客户地址"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-collapse-item>
                </el-collapse>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                <el-form-item prop="jhfhsj" label="计划发货">
                  <el-date-picker
                    v-model="formDialog1.jhfhsj"
                    type="datetime"
                    placeholder="选择发货时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                <el-form-item prop="yqjhsj" label="要求交货">
                  <el-date-picker
                    v-model="formDialog1.yqjhsj"
                    type="datetime"
                    placeholder="选择交货时间">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                <el-form-item prop="jhfs" label="交货方式">
                  <el-select v-model="formDialog1.jhfs" placeholder="请选择">
                    <el-option
                      v-for="item in SHIPMENT.jhfs"
                      :key="item.dictionaryid"
                      :label="item.value"
                      :value="item.dictionaryid">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
                <el-form-item prop="fylx" label="订单类型">
                  <el-select v-model="formDialog1.fylx"
                             filterable
                             remote
                             placeholder="请选择订单类型"
                             @change="dialogRemoteLx"
                             :remote-method="dialogRemoteDdlx">
                    <el-option
                      v-for="item in dialog.wmsPurchaseOrder"
                      :key="item.id"
                      :label="item.ddlx"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
                <el-form-item prop="zdsh" label="审核状态" v-show="formDialog1.zdsh!==''">
                  <div class="s-content">
                    <el-tag type="info">{{formDialog1.zdsh}}</el-tag>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
          </s-form>
        </el-tab-pane>
        <el-tab-pane label="发运订单明细" name="2" disabled>
          <div class="__table">
            <el-button @click="dialogMxOpen('add')" class="__table_button"><i class="el-icon-plus"></i></el-button>
            <s-table :table="tableMx" ref="tableMx" @http="tableWatch" :control="false">
              <el-table-column
                fixed="right"
                align="center"
                slot="operation"
                class-name="operationMore"
                label="操作"
                width="80">
                <template scope="s">
                  <el-button type="success" icon="edit" size="mini" @click="dialogMxOpen('put', s.row)"></el-button>
                  <el-button type="danger" icon="delete" size="mini" @click="tableMxDelete(s.$index)"></el-button>
                </template>
              </el-table-column>
            </s-table>
          </div>
        </el-tab-pane>
      </el-tabs>
      <el-button slot="footer" v-if="dialog.activeName !== '1'" @click="dialogPre">上一页</el-button>
      <el-button slot="footer" type="info" v-if="dialog.activeName !== '2'" @click="dialogNext">下一页</el-button>
      <el-button slot="footer" type="success" v-if="dialog.activeName === '2'" @click="dialogSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogMx" :close="dialogMxInit">
      <p slot="title">{{dialogMx.title}}</p>
      <s-form :form="formDialogMx" ref="formDialogMx">
        <el-row>
          <el-col :xs="24" :lg="{span: 5, offset: 0}" class="">
            <el-form-item prop="bh" label="货品编号">
              <el-select v-model="formDialogMx.bh"
                         filterable
                         remote
                         @change="dialogMxChangeBh"
                         :remote-method="dialogMxRemoteBh"
                         placeholder="请选择货品编号">
                <el-option
                  v-for="item in dialogMx.hpid"
                  :key="item.goodsId"
                  :label="item.goodsBh"
                  :value="item.goodsBh">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="mc" label="货品名称">
              <el-input
                type="text"
                disabled
                v-model="formDialogMx.mc"
                placeholder="货品名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="bzmc" label="包装名称">
              <el-input
                type="text"
                disabled
                v-model="formDialogMx.bzmc"
                placeholder="包装名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="ms" label="主单位">
              <el-select v-model="formDialogMx.ms"
                         @change="dialogMxChangeMs"
                         placeholder="请选择主单位">
                <el-option
                  v-for="item in dialogMx.pack"
                  :key="item.id"
                  :label="item.ms"
                  :value="item.ms">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 5, offset: 0}" class="">
            <el-form-item prop="tj" label="体积">
              <el-input
                type="text"
                disabled
                v-model="formDialogMxtj"
                placeholder="体积"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="jz" label="净重">
              <el-input
                type="text"
                disabled
                v-model="formDialogMxjz"
                placeholder="净重"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="zl" label="毛重">
              <el-input
                type="text"
                disabled
                v-model="formDialogMxzl"
                placeholder="毛重"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="je" label="金额">
              <el-input
                type="text"
                disabled
                v-model="formDialogMxje"
                placeholder="金额"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 5, offset: 0}" class="">
            <el-form-item prop="yqsl" label="主单位">
              <el-input
                type="text"
                :disabled="formDialogMx.ms && dialogMx.packValue.bzlx !== '0'"
                v-model="formDialogMx.yqsl"
                placeholder="主单位数量"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="yqxdwsl" label="箱单位">
              <el-input
                type="text"
                :disabled="formDialogMx.ms && dialogMx.packValue.bzlx === '0'"
                v-model="formDialogMx.yqxdwsl"
                placeholder="箱单位数量"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="kwid" label="库位">
              <el-select v-model="formDialogMx.kwid"
                         filterable
                         remote
                         placeholder="请选择库位"
                         @change="dialogChangeKwmc"
                         :remote-method="dialogRemoteKwmc">
                <el-option
                  v-for="item in dialogMx.kwid"
                  :key="item.id"
                  :label="item.mc"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="pc" label="批次号">
              <el-select v-model="formDialogMx.pc"
                         :disabled="!formDialogMx.bh"
                         filterable
                         remote
                         placeholder="请选择批次号"
                         :remote-method="dialogRemotePch">
                <el-option
                  v-for="item in dialogMx.pcid"
                  :key="item.hppc"
                  :label="item.hppc"
                  :value="item.hppc">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 5, offset: 0}" class="">
            <el-form-item prop="scrq" label="生产日期">
              <el-select v-model="formDialogMx.scrq"
                         :disabled="!formDialogMx.bh"
                         filterable
                         remote
                         placeholder="请选择生产日期"
                         :remote-method="dialogRemoteScrq">
                <el-option
                  v-for="item in dialogMx.rqid"
                  :key="item.scrq"
                  :label="item.scrq"
                  :value="item.scrq">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 5, offset: 1}" class="">
            <el-form-item prop="je" label="总金额">
              <el-input
                type="text"
                v-model="formDialogMx.sum"
                placeholder="总金额"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 23, offset: 0}" class="">
            <el-form-item prop="bz" label="备注">
              <el-input
                type="textarea"
                v-model="formDialogMx.bz"
                placeholder="备注"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogMxSave">保存</el-button>
    </s-dialog>
  </div>
</template>

<script>
  import {AutoVue, AutoPromise, FormatterTime} from '~/plugins/Tools';

  function __form1_kh () {
    return {
      khbh: { value: '', rule: [], cRemarks: '' },
      khmc: { value: '', rule: [], cRemarks: '' },
      khdz: { value: '', rule: [], cRemarks: '' },
      xlmc: { value: '', rule: [], cRemarks: '' },
      lxrxm: { value: '', rule: [], cRemarks: '' },
      lxrdh: { value: '', rule: [], cRemarks: '' },
    };
  }
  function __form1 () {
    return {
      khid: { value: '', rule: [ 'vNull__change' ], cRemarks: '' },
      ...__form1_kh(),
      fybh: { value: '1', rule: [ 'vNull' ], cRemarks: '' },
      fylx: { value: '', rule: [ 'vNull__change' ], cRemarks: '' },
      yxj:
        { value: 1,
          rule: [ 'vNull__change' ],
          cRemarks: '1、1， 2、2，3、3,4、4,5、5' },
      zdsh: { value: '', rule: [], cRemarks: '0、未审核 1、已审核' },
      bz: { value: '', rule: [ '' ], cRemarks: '' },
      cjsj: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      jhfhsj: { value: '', rule: [ 'vNull' ], cRemarks: '', type: 'Date' },
      yqjhsj: { value: '', rule: [ 'vNull' ], cRemarks: '', type: 'Date' },
      jhfs: { value: '0', rule: [ 'vNull__change' ], cRemarks: '0：发运 1：自提' },
    };
  }
  function __tableMx () {
    return {
      column: [
        { label: '货品编号',
          prop: 'bh',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '货品名称',
          prop: 'mc',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '包装名称',
          prop: 'bzmc',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '主单位',
          prop: 'ms',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '预期数量',
          prop: 'yqsl',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '预期数量',
          prop: 'yqxdwsl',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '分配数量',
          prop: 'fpsl',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '拣货数量',
          prop: 'jhsl',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '发运数量',
          prop: 'fysl',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '库位名称',
          prop: 'kwmc',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '批次号',
          prop: 'pc',
          minWidth: '0px',
          cRemarks: '',
          search: false },
        { label: '生产日期',
          prop: 'scrq',
          minWidth: '0px',
          formatter: (row, column) => {
            return FormatterTime(row[column.property || column], 3);
          },
          cRemarks: '',
          search: false },
        { label: 'SO状态',
          prop: 'show_fymxzt',
          minWidth: '0px',
          cRemarks: '0、初始 1、部分分配2、全部分配 3、部分发运4、全部发运5、订单取消6、订单完成',
          search: true },
      ],
      key: 'id',
      tableColumn: 6,
    };
  }

  function __formDialogMx_goods () { // hpid
    return {
      mc: { value: '', rule: [], cRemarks: '' },
      bzmc: { value: '', rule: [], cRemarks: '' },
    };
  }
  function __formDialogMx_pack () {
    return {
      tj: { value: '', rule: [], cRemarks: '' },
      jz: { value: '', rule: [], cRemarks: '' },
      zl: { value: '', rule: [], cRemarks: '' },
      je: { value: '', rule: [], cRemarks: '' },
      zdwsl: { value: '', rule: [], cRemarks: '' },
    };
  }
  function __formDialogMx () {
    return {
      bh: { value: '', rule: ['vNull__change'], cRemarks: '' },
      ...__formDialogMx_goods(),
      ms: { value: '', rule: ['vNull__change'], cRemarks: '' },
      ...__formDialogMx_pack(),
      yqsl: { value: '', rule: ['vNumber', 'vZNumber', 'vZZNumber'], cRemarks: '' },
      sum: { value: 0, rule: ['vNumber', 'vZNumber', 'vZZNumber'], cRemarks: '' },
      yqxdwsl: { value: '', rule: ['v_XiangYanZhen'], cRemarks: '' },
      kwid: { value: '', rule: ['vNull__change'], cRemarks: '' },
      pc: { value: '', rule: ['vNull__change'], cRemarks: '' },
      scrq: { value: '', rule: ['vNull__change'], cRemarks: '' },
    };
  }
  export default AutoVue({
    name: 'outOperation_shipment-FEcarWms',
    store: ['DICTIONARY_shipment', 'SHIPMENT', 'USER'],
    data: {
      table: {
        column: [
          { label: 'wms创建时间',
            prop: 'cjsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
          { label: '客户创建时间',
            prop: 'khcjsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
          { label: 'SO编号',
            prop: 'fybh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户订单号',
            prop: 'khddh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: 'SO类型',
            prop: 'show_fylx',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户编号',
            prop: 'khbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户名称',
            prop: 'khmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '联系人',
            prop: 'lxrxm',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户地址',
            prop: 'khdz',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '审核状态',
            prop: 'show_shzt',
            minWidth: '0px',
            cRemarks: '0、未审核 1、已审核',
            search: true },
          { label: '拆单状态',
            prop: 'show_cdzt',
            minWidth: '0px',
            cRemarks: '0、未拆单 1、已拆单',
            search: true },
          { label: '交货方式',
            prop: 'show_jhfs',
            minWidth: '0px',
            cRemarks: '0、发运 1、自提',
            search: true },
          { label: '装箱状态',
            prop: 'show_zxzt',
            minWidth: '0px',
            cRemarks: '0、未装箱 1、部分装箱 2、全部装箱',
            search: true },
          { label: '波次状态',
            prop: 'show_bczt',
            minWidth: '0px',
            cRemarks: '0、未加入 1、已加入',
            search: true },
          { label: '拣货状态',
            prop: 'show_jhzt',
            minWidth: '0px',
            cRemarks: '0、初始 1、部分拣货 2、全部拣货',
            search: true },
          { label: 'SO状态',
            prop: 'show_fyzt',
            minWidth: '0px',
            cRemarks: '0、初始 1、部分分配2、全部分配 3、部分发运4、全部发运5、订单取消6、订单完成',
            search: true },
          /*
          { label: '客户ID',
            prop: 'khid',
            minWidth: '0px',
            cRemarks: '',
            search: true },
            */
          { label: '备注',
            prop: 'bz',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '计划发货时间',
            prop: 'jhfhsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
          { label: '要求交货时间',
            prop: 'yqjhsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
        ],
        url: '/wmsshipmentorder/list',
        key: 'id',
        muti: false,
        popover: {
          width: 900,
        },
        autoColumnClose: true,
        tableColumn: 2,
      },

      dialog: {
        title: '新增',
        row: {},
        id: [],
        activeName: '1',
        activeNameCollapse: '1',
        wmsPurchaseOrder: [],
        wmsshipmentorder: [],
        hpbh: [],
        size: 'large',
      },
      formDialog1: __form1(),
      tableMx: __tableMx(),

      dialogMx: {
        title: '新增',
        size: 'large',
        row: {},
        hpid: [],
        pack: [],
        packValue: {
          bzlx: '0',
        },
        data: {},
        step: {},
        sum: 0,

        pcid: [],
        rqid: [],
        kwid: [],

        kwData: {},
      },
      formDialogMx: __formDialogMx(),

      dialogSearch: {
        row: {},
      },
    },
    transition: 'slide-fade',
    methods: {
      tableEdit (row) {},
      tableDelete (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将作废选择的发运订单', '确认作废？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsshipmentorder/updateSfyx', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableExamine (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将审核选择的发运订单', '确认审核？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsshipmentorder/updateShzt', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableImport (row) {
        this.$confirm('您将导入该发货订单。', '确认导入？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        });
      },
      tableComplete (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将标记选择的发运订单', '确认标记？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsshipmentorder/updateZt', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableCreate (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的发运订单进行创建波次的操作', '确认创建波次？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmswave/add', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableRemove (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的发运订单进行订单拆单的操作', '确认订单拆单？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsSplit/split', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableCancel (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的发运订单进行取消拆单的操作', '确认取消拆单？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsSplit/cancel', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableAllot (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将分配选择的发运订单', '确认分配？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsdistribution/distribution', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableAdditionalAllot (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将追加分配选择的发运订单', '确认追加分配？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableCancelAllot (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将取消分配选择的发运订单', '确认取消分配？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsdistribution/cancelDistribution', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tablePacking (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的发运订单进行装箱的操作', '确认装箱？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableAdditionalPacking (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的发运订单进行追加装箱的操作', '确认追加装箱？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tablePicking (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的发运订单进行拣货操作', '确认拣货？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmspicking/pick', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableAdditionalPicking (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的发运订单进行追加拣货操作', '确认追加拣货？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableShipment (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将发运选择的发运订单', '确认发运？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmspicking/despacth', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },
      tableAdditionalShipment (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将追加发运选择的发运订单', '确认追加发运？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },

      dialogInit () {
        this.dialog.activeName = '1';
        this.dialog.activeNameCollapse = '1';
        this.formDialog1 = {
          ...this.formDialog1,
          ...this.ObjectClone(__form1()),
        };
        this.resetFields('formDialog1');
        this.tableClear('tableOrder');
      },
      async dialogOpen (type, more) {
        if (type) {
          type = type.toUpperCase();
        } else return;
        switch (type) {
        case 'ADD':
          await AutoPromise([
            async () => {
              if (!this.DICTIONARY_shipment) {
                await this.USE('DICTIONARY_shipment');
              }
            },
            async () => {
              await this.dialogRemoteDdlx('');
            },
            async () => {
              await this.dialogRemoteKhbh('');
            },
            async () => {
              let {bh} = await this.get('/wmsshipmentorder/getBh');
              this.formDialog1.fybh = bh;
            },
          ]);
          this.dialog.title = '新增';
          break;
        case 'PUT':
          this.dialog.row = more;
          this.dialog.title = '修改';
          this.formDialog1 = {
            ...this.formDialog1,
            ...this.ObjectClone(__form1(), more),
          };
          break;
        }
        this.dialog.visible = true;
      },
      dialogPre () {
        this.dialog.activeName = parseInt(this.dialog.activeName) - 1 + '';
      },
      dialogNext () {
        this.VALIDATE('formDialog' + this.dialog.activeName, option => {
          this.dialog.activeName = parseInt(this.dialog.activeName) + 1 + '';
        });
      },
      tableMxDelete (index) {
        this.$confirm('您将删除该条明细。', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(() => {
            this.tableMx.data.splice(index, 1);
          });
      },
      dialogSave () {
        this.VALIDATE('formDialog1', async option => {
          let kh = __form1_kh();
          for (let index in kh) {
            if (kh.hasOwnProperty(index)) {
              delete option[index];
            }
          }
          delete option.zdsh;
          let json = {
            ...option,
            wsodList: this.tableMx.data,
          };
          try {
            await this.post('/wmsshipmentorder/add', json);
            this.dialogInit();
            this.tableWatch('table');
            this.dialog.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
      },

      dialogMxInit () {
        this.dialogMx.row = {};
        this.dialogMx.step = {};
        this.dialogMx.packValue = {
          bzlx: '0',
        };
        this.dialogMx.data = {};
        this.dialogMx.hpid = [];
        this.dialogMx.pack = [];
        this.dialogMx.pcid = [];
        this.dialogMx.rqid = [];
        this.dialogMx.kwid = [];
        this.formDialogMx = {
          ...this.formDialogMx,
          ...this.ObjectClone(__formDialogMx()),
        };
        this.resetFields('formDialogMx');
        this.dialogMx.title = '新增';
      },
      async dialogMxOpen (type, row) {
        if (type) {
          type = type.toUpperCase();
        } else return;
        await AutoPromise([
          async () => {
            this.dialogMxRemoteBh('');
          },
        ]);
        switch (type) {
        case 'ADD':
          this.dialogMx.title = '新增';
          this.dialogRemoteKwmc('');
          break;
        case 'PUT':
          this.dialogMx.title = '修改';
          this.dialogMx.row = row;
          this.dialogMx.step = Object.assign({}, row);
          this.dialogRemoteKwmc(row.kwmc);
          if (!this.$refs.formDialogMx) {
            setTimeout(() => {
              let unwatch = this.$watch('dialogMx.pack', () => {
                unwatch();
                if (this.dialogMx.pack.length > 1) {
                  let unwatch2 = this.$watch('formDialogMx.ms', () => {
                    unwatch2();
                    let unwatch3 = this.$watch('formDialogMx.sum', () => {
                      unwatch3();
                      this.formDialogMx.sum = this.dialogMx.step.je || 0;
                    });
                    this.formDialogMx.yqsl = this.dialogMx.step.yqsl || 0;
                    this.formDialogMx.yqxdwsl = this.dialogMx.step.yqxdwsl || '';
                    this.dialogRemotePch(row.pc);
                    this.dialogRemoteScrq(this.formatterTime(row.scrq));
                    this.formDialogMx.pc = this.dialogMx.step.pc || '';
                    this.formDialogMx.scrq = this.dialogMx.step.scrq || '';
                  });
                  this.formDialogMx.ms = this.dialogMx.step.ms;
                }
              });
              this.formDialogMx = {
                ...this.formDialogMx,
                ...this.ObjectClone(__formDialogMx(), row),
              };
            }, 250);
          } else {
            let unwatch = this.$watch('dialogMx.pack', () => {
              unwatch();
              if (this.dialogMx.pack.length > 1) {
                let unwatch2 = this.$watch('formDialogMx.ms', () => {
                  unwatch2();
                  let unwatch3 = this.$watch('formDialogMx.sum', () => {
                    unwatch3();
                    this.formDialogMx.sum = this.dialogMx.step.je || 0;
                  });
                  this.formDialogMx.yqsl = this.dialogMx.step.yqsl || 0;
                  this.formDialogMx.yqxdwsl = this.dialogMx.step.yqxdwsl || '';
                  this.dialogRemotePch(row.pc);
                  this.dialogRemoteScrq(this.formatterTime(row.scrq));
                  this.formDialogMx.pc = this.dialogMx.step.pc || '';
                  this.formDialogMx.scrq = this.dialogMx.step.scrq || '';
                });
                this.formDialogMx.ms = this.dialogMx.step.ms;
              }
            });
            this.formDialogMx = {
              ...this.formDialogMx,
              ...this.ObjectClone(__formDialogMx(), row),
            };
          }
          break;
        }
        this.dialogMx.visible = true;
      },
      dialogMxChangeBh (goodsBh) {
        this.formDialogMx.yqsl = '';
        this.formDialogMx.yqxdwsl = '';
        this.dialogMx.hpid.forEach(value => {
          if (value.goodsBh === goodsBh) {
            this.dialogMx.data = value;
            this.formDialogMx.mc = value.goodsName;
            this.formDialogMx.bzmc = value.bzmc;
            this.formDialogMx.ms = '';
            this.formDialogMx.scrq = '';
            this.formDialogMx.pc = '';
            this.dialogMx.packValue = {
              bzlx: '0',
            };
            this.dialogMxRemotePack(value.packId);
            this.dialogRemoteScrq('');
            this.dialogRemotePch('');
          }
        });
      },
      async dialogMxRemoteBh (Bh) {
        this.dialogMx.hpid = await this.post('/wmsshipmentorder/getGoodsByHzid', {
          bh: Bh,
        });
      },
      dialogMxChangeMs (ms) {
        this.formDialogMx.yqsl = '';
        this.formDialogMx.yqxdwsl = '';
        this.dialogMx.pack.forEach(value => {
          if (value.ms === ms) {
            this.dialogMx.packValue = value;
            this.formDialogMx = {
              ...this.formDialogMx,
              ...this.ObjectClone(__formDialogMx_pack(), value),
            };
          }
        });
      },
      async dialogRemoteDdlx (query) {
        this.dialog.wmsPurchaseOrder = await this.post('/wmsshipmentorder/getPoLx', {ddlx: query});
      },
      async dialogRemoteLx (id) {
        this.dialog.wmsPurchaseOrder.forEach(value => {
          if (value.id === id) {
            this.formDialog1.zdsh = value.show_zdsh;
          }
        });
      },
      async dialogRemoteKhbh (query) {
        this.dialog.wmsshipmentorder = await this.post('/wmsshipmentorder/getCusInfo', {khbh: query});
      },
      dialogRemoteKhbhid (id) {
        this.dialog.wmsshipmentorder.forEach(value => {
          if (value.id === id) {
            this.formDialog1 = {
              ...this.formDialog1,
              ...this.ObjectClone(__form1_kh(), value),
            };
          }
        });
      },
      async dialogRemoteKwmc (query) {
        let data = {};
        data = await this.post('/wmsshipmentorder/getLiLibraryPosition', {mc: query});
        this.dialogMx.kwid = data;
      },
      dialogChangeKwmc (id) {
        this.dialogMx.kwid.forEach(item => {
          if (item.id === id) {
            this.dialogMx.kwData = item;
          }
        });
      },
      async dialogRemotePch (query) {
        this.dialogMx.pcid = await this.post('/wmsshipmentorder/getWmsStock', {
          hpid: this.dialogMx.data.goodsId,
          hppc: query,
        });
      },
      async dialogRemoteScrq (query) {
        this.dialogMx.rqid = await this.post('/wmsshipmentorder/getWmsStockScrq', {
          hpid: this.dialogMx.data.goodsId,
          scrq: query,
        });
      },
      async dialogMxRemotePack (packId) {
        this.dialogMx.pack = await this.get('/wmsPurchaseOrder/packDetailList/' + packId);
      },
      dialogMxSave () {
        this.VALIDATE('formDialogMx', async option => {
          let table = 'tableMx';
          if (this.dialogSearch.row.id) {
            table = 'tableSearch';
          }
          if (table === 'tableMx') {
            let check = true;
            this[table].data.forEach((value, index) => {
              if (this.dialogMx.row.bh === value.bh) {
                this[table].data.splice(index, 1);
              } else if (this.dialogMx.data.goodsBh === value.bh) {
                this.$alert(`发现货品 ${value.bh} 已经存在！`, '提示');
                check = false;
              }
            });
            if (check) {
              this[table].data.push({
                ...option,
                hpid: this.dialogMx.data.goodsId,
                zdw: this.dialogMx.packValue.id,
                je: this.formDialogMx.sum,
                kwmc: this.dialogMx.kwData.mc,
                scrq: FormatterTime(option.scrq, 31),
              });
              this[table].total++;
              this.dialogMxInit();
              this.dialogMx.visible = false;
            }
          } else {
            try {
              if (this.dialogMx.title === '新增') {
                await this.post('/wmsPurchaseOrderDetailed/add', {
                  ...option,
                  hpid: this.dialogMx.data.goodsId,
                  zdw: this.dialogMx.packValue.id,
                  sscgdid: this.dialogSearch.row.id,
                  je: this.formDialogMx.sum,
                });
              } else {
                await this.post('/wmsPurchaseOrderDetailed/edit', {
                  ...option,
                  hpid: this.dialogMx.data.goodsId,
                  zdw: this.dialogMx.packValue.id,
                  sscgdid: this.dialogSearch.row.id,
                  id: this.dialogMx.row.id,
                  je: this.formDialogMx.sum,
                });
              }
              this.tableSearch.data = await this.get('/wmsPurchaseOrder/wmsPurchaseOrderDetailList/' + this.dialogSearch.row.id);
              this.dialogMxInit();
              this.dialogMx.visible = false;
            } catch (err) {
              console.error(err);
            }
          }
        });
      },

      async dialogSearchOpen (row) {
        this.dialogSearch.row = row;
        this.tableSearch.data = await this.get('/wmsPurchaseOrder/wmsPurchaseOrderDetailList/' + row.id);
        this.dialogSearch.visible = true;
      },
      async dialogMxRemoteBz (packId) {
        this.dialogOrder.packId = await this.get('/wmsPurchaseOrder/packDetailList/' + packId);
      },
    },
    computed: {
      formDialogMxje: function () {
        if (this.formDialogMx.yqsl) {
          return this.formDialogMx.je * this.formDialogMx.yqsl;
        } else {
          return this.formDialogMx.je;
        }
      },
      formDialogMxzl: function () {
        if (this.formDialogMx.yqsl) {
          return this.formDialogMx.zl * this.formDialogMx.yqsl;
        } else {
          return this.formDialogMx.zl;
        }
      },
      formDialogMxjz: function () {
        if (this.formDialogMx.yqsl) {
          return this.formDialogMx.jz * this.formDialogMx.yqsl;
        } else {
          return this.formDialogMx.jz;
        }
      },
      formDialogMxtj: function () {
        if (this.formDialogMx.yqsl) {
          return this.formDialogMx.tj * this.formDialogMx.yqsl;
        } else {
          return this.formDialogMx.tj;
        }
      },
    },
    watch: {
      'formDialogMx.yqsl': function (item) {
        let sum = parseInt(this.formDialogMxje);
        this.formDialogMx.sum = isNaN(sum) ? 0 : sum;
        if (item && this.dialogMx.packValue.bzlx === '0' && this.dialogMx.packValue.zdwsl) {
          let zdwsl = parseInt(this.dialogMx.packValue.zdwsl);
          let source = parseInt(item);
          this.formDialogMx.yqxdwsl = `${Math.floor(source / zdwsl)}箱${source % zdwsl}件`;
        }
      },
      'formDialogMx.yqxdwsl': function (item) {
        if (item && this.dialogMx.packValue.bzlx !== '0' && this.dialogMx.packValue.zdwsl) {
          let reg = /(\d{1,5})箱(\d{1,5})件/;
          if (reg.test(item)) {
            let zdwsl = parseInt(this.dialogMx.packValue.zdwsl);
            let source = reg.exec(item);
            let xiang = parseInt(source[1]);
            let jian = parseInt(source[2]);
            this.formDialogMx.yqsl = xiang * zdwsl + jian + '';
          }
        }
      },
    },
    mounted: function () {
      this.tableWatch('table');
      console.log(this);
    },
  });
</script>
<style scoped lang="scss">
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
</style>

<style lang="scss">

</style>
